<?php
class Agitum_View_Helper_CanRoute extends Zend_View_Helper_Abstract
{
	public function CanRoute($route, $action)
    {
        $auth = Zend_Auth::getInstance();
		$role = ($auth->hasIdentity()) ? (string)$auth->getIdentity()->role : 'guest';
		
		$controller = $route->controller;
		$module = $route->module;

		$resource = $module.'_'.$controller;
		$privelege = $action;

		$acl = Zend_Registry::get('Zend_Acl');
		
		if( $acl->has($resource) && $acl->isAllowed((string)$role, $resource, $privelege))
		    return true;
        
        return false;
    }
}